#include<stdio.h>
main()
{
int a[3][4]={{2,6,4,3},{5,8,7,2},{9,1,6,5}};
int i,j;
for(i=0;i<=2;i++)
{
for(j=0;j<=3;j++)
printf("%d ",a[i][j]);
printf("\n");
}
}
#include<stdio.h>
main()
{
int a[3][4]={{2,6,4,3},{5,8,7,2},{9,1,6,5}};
int i,j,s=0;
for(i=0;i<=2;i++)
{
for(j=0;j<=3;j++)
s=s+a[i][j];
}
printf("Sum is %d",s);
}
#include<stdio.h>
main()
{
int a[4][4],i,j;
printf("Enter a matrix of size 4X4 \n");
for(i=0;i<=3;i++)
for(j=0;j<=3;j++)
scanf("%d",&a[i][j]);
printf("Matrix array:\n");
for(i=0;i<=3;i++)
{
for(j=0;j<=3;j++)
printf("%d ",a[i][j]);
printf("\n");
}
}
#include<stdio.h>
main()
{
int a[3][4],i,j,s=0;
printf("Enter a matrix of size 3X4 \n");
for(i=0;i<=2;i++)
for(j=0;j<=3;j++)
scanf("%d",&a[i][j]);
for(i=0;i<=2;i++)
{
for(j=0;j<=3;j++)
s=s+a[i][j];
}
printf("Sum is %d ",s);
}
#include<stdio.h>
main()
{
int a[4][5],i,j,s=0 ;
printf("Enter a matrix of size 4X5 \n");
for(i=0;i<=3;i++)
for(j=0;j<=4;j++)
scanf("%d",&a[i][j]);
for(i=0;i<=3;i++)
{
s=0;
for(j=0;j<=4;j++)
s=s+a[i][j];
printf("\nSum of row %d is %d ",i,s);
}
}
#include<stdio.h>
main()
{
int a[4][5],b[4][5],i,j;
printf("Enter a matrix of size 4X5 \n");
for(i=0;i<=3;i++)
for(j=0;j<=4;j++)
{
scanf("%d",&a[i][j]);
b[i][j]=a[i][j];
}
printf("Copy array: \n");
for(i=0;i<=3;i++)
{
for(j=0;j<=4;j++)
{
printf("%d ",b[i][j]);
}
printf("\n");
}
}
#include<stdio.h>
main()
{
int a[3][3],b[3][3],s[3][3],i,j;
printf("Enter a matrix of size 3X3 \n");
for(i=0;i<=2;i++)
for(j=0;j<=2;j++)
scanf("%d",&a[i][j]);
printf("Enter a matrix of size 3X3 \n");
for(i=0;i<=2;i++)
for(j=0;j<=2;j++)
scanf("%d",&b[i][j]);
for(i=0;i<=2;i++)
for(j=0;j<=2;j++)
s[i][j]=a[i][j]+b[i][j];
printf("Sum of matrix: \n");
for(i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
{
printf("%d ",s[i][j]);
}
printf("\n");
}
}
#include<stdio.h>
main()
{
int a[4][4],i,j,b[4][4];
printf("Enter a matrix of size 4X4 ");
for(i=0;i<=3;i++)
for(j=0;j<=3;j++)
scanf("%d",&a[i][j]);
for(i=0;i<=3;i++)
for(j=0;j<=3;j++)
b[j][i]=a[i][j];
printf("\nTranspose of Matrix :\n");
for(i=0;i<=3;i++)
{
for(j=0;j<=3;j++)
printf("%d ",b[i][j]);
printf("\n");
}
}
#include<stdio.h>
main()
{
int a[43][3],i,j,s=0;
printf("Enter a matrix of size 3X3 \n");
for(i=0;i<=2;i++)
for(j=0;j<=2;j++)
scanf("%d",&a[i][j]);
printf("UPPER TRIANGULAR matrix \n");
for(i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
{
if(i>j)
a[i][j]=0;
printf("%d ",a[i][j]);
}
printf("\n");
}
}
#include<stdio.h>
main()
{
int a[3][3],i,j,s=0;
printf("Enter a matrix of size 3X3 \n");
for(i=0;i<=2;i++)
for(j=0;j<=2;j++)
scanf("%d",&a[i][j]);
printf("Lower TRIANGULAR matrix\n");
for(i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
{
if(i<j)
a[i][j]=0;
printf("%d ",a[i][j]);
}
printf("\n");
}
}